package com.quartet.modules.quartz.utils;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.http.HttpUtil;
import com.quartet.api.MapServerException;
import com.quartet.api.ResultErrorEnum;
import com.quartet.modules.multimedia.dto.MediaSendCommandRequestDto;
import com.quartet.modules.stock.dto.TTerminalServiceMessageDto;
import com.quartet.utils.JsonTool;
import com.quartet.utils.constant.MapServerConstant;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
 * http请求
 */
@Slf4j
public class HttpUtils {
    
    public static void sendAuthInfo(List<TTerminalServiceMessageDto> tTerminalServiceMessageDtoList){
        //发异步送给协议解析方
        CompletableFuture.runAsync(()->{
            String json = JsonTool.beanToJson(tTerminalServiceMessageDtoList);
            String result = HttpUtil.post(MapServerConstant.AUTHORITY, json);
            log.info("调用http://8.141.63.229:97/terminal/authority，参数为：{}，返回信息：{}", json, result);
            if (!"success".equals(result)) {
                throw new MapServerException(ResultErrorEnum.BMKPF003);
            }
        });
    }
}
